//3.3
package chap03;

public class chap3 {
    static class Student{
        String name;
        int age;
        void read(){
            System.out.println("大家好，我是"+name+"，年龄"+age);
        }
    }
    public class Example03{
        public static void main(String[] args){
         Student stu = new Student();
         stu.name ="张三";
         stu.age =-18;
         stu.read();
        }
    }
}
//3.4
class Student{
    private String name;
    private int age;
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    public int getAge(){
        return age;
    }
    public void setAge(int age){
        if (age<=0){
            System.out.println("您输入的年龄有误！");
        }else{
            this.age = age;
        }
    }
    public void read(){
        System.out.println("大家好，我是"+name+"，年龄"+age);
    }
}
